// This is a ROS version of the standard "hello , world"
// program.
// This header defines the standard ROS classes .

#include "voice_simple.hpp"
#include "xmlTest.hpp"
using namespace std;
int main (int argc , char **argv ) {


    //调用此函数给其他回调函数得以执行(比例程未使用回调函数)
    // //vel_pub会在主题"/cmd_vel"(机器人速度控制主题)里广播geometry_msgs::Twist类型的数据
    // ROS_INFO("draw_circle start...");//输出显示信息
    // while(ros::ok())
    // {
    //     geometry_msgs::Twist vel_cmd; //声明一个geometry_msgs::Twist 类型的对象vel_cmd，并将速度的值赋值到这个对象里面
 
    //     vel_cmd.linear.x = 2.0;//前后（+-） m/s
    //     vel_cmd.linear.y = 0.0;  //左右（+-） m/s
    //     vel_cmd.linear.z = 0.0;
 
    //     vel_cmd.angular.x = 0;
    //     vel_cmd.angular.y = 0;
    //     vel_cmd.angular.z = 1.8; //机器人的自转速度，+左转，-右转，单位是rad/s
    //     vel_pub.publish(vel_cmd); //赋值完毕后，发送到主题"/cmd_vel"。机器人的核心节点会从这个主题接受发送过去的速度值，并转发到硬件体上去执行
 
    //     ros::spinOnce();//调用此函数给其他回调函数得以执行(比例程未使用回调函数)
    // }

    char* a = recognize();
    cout<<a;
    // cout<<strcmp("没有识别结果！\n",a)<<endl;
    // cout<<strcmp("没有识别结果！\n",a)<<endl;

    if(strcmp("没有识别结果！\n",a)==0){
        system("play /home/babyxin/catkin_ws/src/xf_asr/audio/exit.wav");
        return 0;
    }
    char* direction = getDicretion(a);


	system("play /home/babyxin/catkin_ws/src/xf_asr/audio/test4.wav");
    // cout<<direction<<endl;
    // ros::spin();

    if (strcmp("向前",direction)==0)
    {   
        system("rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist [1,0.0,0.0] [0.0,0.0,0]");
    }else if (strcmp("向后",direction)==0)
    {   
        system("rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist [-1.0,0.0,0.0] [0.0,0.0,0]");
    }else if (strcmp("向左",direction)==0)
    {
        system("rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist [0,0.0,0.0] [0.0,0.0,0.785]");
    }else if (strcmp("向右",direction)==0)
    {
        system("rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist [1,0.0,0.0] [0.0,0.0,-0.785]");
    }
    
    

    

    return 0;

// Initialize the ROS system .
// ros::init (argc, argv, "hello_ros" ) ;
// Establish this program as a ROS node .
// ros::NodeHandle nh ;
// Send some output as a log message .
// ROS_INFO_STREAM( " Hello, ROS!!!!" ) ;
cout<<"test"<<endl;
}